//=============================================================================
// System  : MatchKit
// File    : TraceEntry.cs
// Author  : Fabio Bussu  (matchkit@fabiobussu.it)
// Updated : 04/16/2013
// Note    : Copyright 2013, Fabio Bussu, All rights reserved
//
// This code is published under the Microsoft Public License (Ms-PL). A copy
// of the license should be distributed with the code.  It can also be found
// at the project website: http://matchkit.codeplex.com. This notice, the
// author's name, and all copyright notices must remain intact in all
// applications, documentation, and source files.
//
// Version     Date     Who  Comments
// ============================================================================
// 1.0.0.0  04/16/2013   FB  First draft
//=============================================================================
using System;
using System.Runtime.Serialization;

namespace MatchKit
{
	/// <summary>
	/// Collects informations of a trace written during the matching process.
	/// </summary>
	/// <threadsafety static="true" instance="false" />
	/// <serialization binary="true" contract="true" />
	/// <conceptualLink target="0a06b2a9-5f58-409a-ba62-639cfd77bca7" />
	#if DC
	[DataContract]
	#endif
	#if SZ
	[Serializable]
	#endif
	public class TraceEntry
	{
		/// <summary>
		/// Initializes a new instance of the <see cref="T:MatchKit.TraceEntry"/> class. 
		/// </summary>
		/// <param name="reason">Reason of the entry.</param>
		/// <param name="context">Match context. This value cannot be null.</param>
		/// <param name="pattern">Originating pattern. This value cannot be null.</param>
		/// <param name="match">Originaring match.</param>
		/// <param name="message">Custom message.</param>
		public TraceEntry(TraceReason reason, MatchContext context, IPattern pattern
			, Match match, string message)
		{
			if (context == null)
				throw new ArgumentNullException("context", "context cannot be null");
			if (pattern == null)
				throw new ArgumentNullException("pattern", "pattern cannot be null");

			Reason = reason;
			Context = context;
			Pattern = pattern;
			Match = match;
			Message = message;
		}

		/// <summary>
		/// Gets the reason generating the trace.
		/// </summary>
		/// <serialization member="true" />
		#if DC
		[DataMember]
		#endif
		public TraceReason Reason { get; private set; }

		/// <summary>
		/// Gets the matching context. This value cannot be null.
		/// </summary>
		/// <serialization member="true" />
		#if DC
		[DataMember]
		#endif
		public MatchContext Context { get; private set; }

		/// <summary>
		/// Gets the originating pattern. This value cannot be null.
		/// </summary>
		/// <serialization member="true" />
		#if DC
		[DataMember]
		#endif
		public IPattern Pattern { get; private set; }

		/// <summary>
		/// Gets the resulted match, when the reason is <see cref="F:MatchKit.TraceReason.MatchFailed"/> 
		/// or <see cref="F:MatchKit.TraceReason.MatchSuccess"/>
		/// </summary>
		/// <serialization member="true" />
		#if DC
		[DataMember]
		#endif
		public Match Match { get; private set; }

		/// <summary>
		/// Gets the custom message.
		/// </summary>
		/// <serialization member="true" />
		#if DC
		[DataMember]
		#endif
		public string Message { get; private set; }
	}
}
